<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
		<title>基本信息</title>
		<link rel="stylesheet" href="__AGENT__/css/iconfont.css" />
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
	</head>

	<body>
		{include file="public/header" /}
		<div class="index_conbox">
			<div class="index_content clearfix">
				{include file="public/lefter" /}
				<div class="right">

					<div class="rigtop">
						<span class="title">帐号中心</span>
					</div>
					<div class="indrig_con" style="position: relative;">
						<div class="zizh_btnbox" style="top: -88px; right: 20px;">
							<button class="zizh_btn" type="button" onclick="show_agent()">修改商家信息</button>
						</div>
						<!--基本信息内容-->
						<div class="shxx_list">
							<div class="shxx_item">
								<div class="shxx_title">基本信息</div>
								<div class="shxx_jibbox clearfix">
									<div class="shxx_jbleft">
										<div class="shxx_row clearfix">
											<div class="left">帐户余额</div>
											<div class="right">
												<p><em>{$data.balance}元</em>
													<a href="javascript:;" onclick="yue_tixian()" class="edit">提现</a>
													<a href="{:url('index/yue_record')}" class="green">记录</a>
												</p>
											</div>
										</div>
										<div class="shxx_row clearfix">
											<div class="left">鼓励金</div>
											<div class="right">
												<p><em>{$data.score}元</em>
													{if condition="$config eq 1"}
													<a href="javascript:;" onclick="score_yue()" class="edit">兑现</a>
													{/if}
													<a href="{:url('index/score_record')}" class="green">记录</a>
													<!--<a href="javascript:;" onclick="set_cz()" class="green">设置会员购买金额</a>-->
												</p>
											</div>
										</div>
										
										
										
										{if $Think.config.open_sq==1}
										<div class="shxx_row clearfix">
											<div class="left">广告余额</div>
											<div class="right">
												<p><em>{$data.ad_money}元</em>
													<a href="javascript:;" onclick="yue_ad()" class="edit">购买</a>
													<a href="{:url('index/ad_record')}" class="green">记录</a>
												</p>
											</div>
										</div>
										{/if}
										<div class="shxx_row clearfix">
											<div class="left">店铺电话</div>
											<div class="right">
												<p><em>{$data.tel}</em>
												</p>
											</div>
										</div>
										<div class="shxx_row clearfix">
											<div class="left">店铺性质</div>
											<div class="right">
												<p><em>
													{switch name="$data.store_property"}
													    {case value="1"}个人{/case}
													    {case value="2"}企业{/case}
													    {default /}个体户
													{/switch}
												</em></p>
											</div>
										</div>
										<div class="shxx_row clearfix">
											<div class="left">商家地址</div>
											<div class="right">
												<p><em id="address">{$data.address}</em>
													<a href="javascript:;" onclick="show_map()" class="edit">修改</a>
												</p>
											</div>
										</div>
										<!--<div class="shxx_row clearfix">
											<div class="left">推广码</div>
											<div class="right">
												<p><em id="address"><a class="iconfont icon-erweima"  href="javascript:;" onclick="tuiguang('{$data.id}')"></a></em>
													<em style="margin-left: 10px;">(提示:用于PC端收银)</em>
												</p>
											</div>
										</div>
										<div class="shxx_row clearfix">
											<div class="left">会员购买码</div>
											<div class="right">
												<p><em id="address"><a class="iconfont icon-erweima"  href="javascript:;" onclick="chongzhi('{$data.id}')"></a></em>
													<em style="margin-left: 10px;">(提示:专属用于本店会员购买)</em>
												</p>
											</div>
										</div>-->
										<div class="shxx_row clearfix">
											<div class="left">打印机设置</div>
											<div class="right">
												<p>
													<a class="edit" onclick="daying_edit()" style="margin-top: 2px;">设置</a>
												</p>
											</div>
										</div>
										
										<div class="shxx_row clearfix" style="color: #000000;margin-left: -30px;margin-bottom: -30px;">
											<form class="layui-form" action="">
												<div class="layui-form-item">
												    <label class="layui-form-label" style="width: 100px;">分佣到账设置</label>
												    <div class="layui-input-block">
												      <input type="radio" name="type" id="type" value="1" title="零钱"  {if $data['type']==1 }checked{/if}>
												      <input type="radio" name="type" id="type" value="2" title="余额"   {if $data['type']==2 }checked{/if}>
												    </div>
												  </div> 
												  <div style="position: absolute;left: 300px;top: -1px;">
												      <button onclick="fy()" style="background: #FF7831;color: white;font-size: 12px;line-height:25px;border: none;width: 45px;border-radius:3px;">保存</button> 
											    </div>
											</form>
										</div>
										
										
										<form class="layui-form">
											<div class="shxx_row clearfix" style="margin-top: 20px;">
												<!--<div class="left" style='width:100px;margin-top:5px'>单商品打印小票</div>
												<div class="right">
													<div class="layui-input-block" style="margin-left: 0;">
														<input type="checkbox" name="open" {if $paid==0 }checked{/if} lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭">
													</div>
												</div>-->
												
												<div class="left" style='width:100px;margin-top:5px;'>门店码打印小票</div>
												<div class="right">
													<div class="layui-input-block" style="margin-left: 0;">
														<input type="checkbox" name="store_open" {if $store_switch==0 }checked{/if} lay-skin="switch" lay-filter="switchTest2" lay-text="开启|关闭">
													</div>
												</div>
											</div>
										</form>

									</div>
									<div class="shxx_jbright">
										<p class="shxx_xmimg">
											{if condition="$data.logo == null"}
											<img src="__OEM__/img/logomr.png"> {else /}
											<img src="{$data.logo}"> {/if}
										</p>
										<p class="shxx_xmnam">{$data.agent_name}</p>
										<p class="shxx_xminfo">{$data.agent_no}</p>
									</div>
								</div>
							</div>
							<div class="shxx_item">
								<div class="shxx_title">账号安全设置</div>
								<div class="shxx_row clearfix">
									<div class="left">登录密码</div>
									<div class="right">
										<p><em>用于登录时使用</em>
											<a href="javascript:;" onclick="return_password()" class="edit">重置</a>
										</p>
									</div>
								</div>
								<div class="shxx_row clearfix">
									<div class="left">操作密码</div>
									<div class="right">
										<p><em>用于重要操作时使用</em>
											<a href="javascript:;" onclick="return_operationpwd()" class="edit">重置</a>
										</p>
									</div>
								</div>
							</div>
							<div class="shxx_item">
								<div class="shxx_title">所属服务机构</div>
								<div class="shxx_row clearfix">
									<div class="left">{$data1.project_name}</div>
									<div class="right">
										<p><em>{$data1.mobile}</em></p>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		{include file="public/footer" /}
	</body>

</html>
<script type="text/javascript">
	function yue_tixian() {
		layer.open({
			type: 2,
			title: '余额提现',
			shadeClose: true,
			shade: 0.8,
			area: ['500px', '300px'],
			content: "{:url('index/yue_tixian')}"
		});
	}

	function daying_edit() {
		var url = "{:url('store/daying_edit')}";
		layer.open({
			type: 2,
			title: '门店打印机设置',
			shadeClose: true,
			shade: 0.8,
			area: ['500px', '550px'],
			content: [url]
		});
	}

	function show_map() {
		layer.open({
			type: 2,
			title: '修改地址',
			shadeClose: true,
			shade: 0.8,
			area: ['1200px', '750px'],
			content: "{:url('index/edit_address')}"
		});
	}

	function return_password() {
		layer.open({
			type: 2,
			title: '重置登录密码',
			shadeClose: true,
			shade: 0.8,
			area: ['500px', '250px'],
			content: "{:url('index/return_password')}"
		});
	}

	function return_operationpwd() {
		layer.open({
			type: 2,
			title: '重置操作密码',
			shadeClose: true,
			shade: 0.8,
			area: ['500px', '250px'],
			content: "{:url('index/return_operationpwd')}"
		});
	}

	function score_yue() {
		layer.open({
			type: 2,
			title: '鼓励金兑换到余额',
			shadeClose: true,
			shade: 0.8,
			area: ['500px', '370px'],
			content: "{:url('index/score_yue')}"
		});
	}

	function yue_score() {
		layer.open({
			type: 2,
			title: '购买鼓励金',
			shadeClose: true,
			shade: 0.8,
			area: ['220px', '265px'],
			content: "{:url('index/yue_score')}"
		});
	}

	function yue_ad() {
		layer.open({
			type: 2,
			title: '购买广告费',
			shadeClose: true,
			shade: 0.8,
			area: ['255px', '285px'],
			content: "{:url('index/yue_ad')}"
		});
	}

	function show_agent() {
		layer.open({
			type: 2,
			title: '修改商家信息',
			shadeClose: true,
			shade: 0.8,
			area: ['960px', '750px'],
			content: "{:url('index/show_agent',['id'=>session('agent_id')])}"
		});
	}

	function show_city_pt() {
		layer.open({
			type: 2,
			title: '修改商家信息',
			shadeClose: true,
			shade: 0.8,
			area: ['460px', '260px'],
			content: "{:url('index/show_city_pt')}"
		});
	}

	function tuiguang(store_id) {
		var url = 'tuiguang?store_id=' + store_id;
		layer.open({
			type: 2,
			title: '商家推广二维码',
			shadeClose: true,
			shade: 0.8,
			area: ['426px', '688px'],
			content: [url]
		});
	}

	function chongzhi(store_id) {
		var url = "{:url('index/chongzhi')}?store_id=" + store_id;
		layer.open({
			type: 2,
			title: '商家购买二维码',
			shadeClose: true,
			shade: 0.8,
			area: ['426px', '688px'],
			content: [url]
		});
	}

	function set_cz() {
		var url = "{:url('index/set_cz')}";
		layer.open({
			type: 2,
			title: '商家购买设置',
			shadeClose: true,
			shade: 0.8,
			area: ['600px', '350px'],
			content: [url]
		});
	} 

	layui.use(['form', 'layedit', 'laydate'], function() {
		var form = layui.form;
        var jquery = layui.jquery;
        var layer = layui.layer;
		//监听指定开关  （单商品打印机开关）
		form.on('switch(switchTest)', function(data) {
			var prt = {$dy_prt};
			if(prt == 0) {
				layer.msg('还未配置打印机');
				return false;
			}
			layer.tips((this.checked ? '打印小票开启' : '打印小票关闭'), data.othis)
			var checked = this.checked;
			var flag = 0; //1开启  0关闭
			if(checked == false) {
				flag = 1;
			}
			isscore(flag);
		});
		
		//监听指定开关（门店码打印机开关）
		form.on('switch(switchTest2)', function(data) {
			var prt = {$dy_prt};
			if(prt == 0) {
				layer.msg('还未配置打印机');
				return false;
			}
			layer.tips((this.checked ? '打印小票开启' : '打印小票关闭'), data.othis)
			var checked = this.checked;
			var flag = 0; //1开启  0关闭
			if(checked == false) {
				flag = 1;
			}
			store_switch(flag);
		});
		
		//监听指定开关（储值卡开关） 
		form.on('switch(switchTest3)', function (data) {
            console.log(data.elem); //得到checkbox原始DOM对象
            console.log(data.elem.checked); //开关是否开启，true或者false
            console.log(data.value); //开关value值，也可以通过data.elem.value得到
            console.log(data.othis); //得到美化后的DOM对象
            var x=data.elem.checked; 
            var flag = 1; //1开启  0关闭 
	            layer.open({
	                content: '商家会员储值卡功能，一旦开启无法关闭'
	                ,btn: ['确定', '取消']
	                ,yes: function(index, layero){ 
	                    data.elem.checked=x;
	                    form.render();
	                    layer.close(index); 
	                    storage_switch(flag);
	                    //按钮【按钮一】的回调
	                }
	                ,btn2: function(index, layero){ 
	                    //按钮【按钮二】的回调
	                    data.elem.checked=!x;
	                    form.render();
	                    layer.close(index);
	                    return false;// 开启该代码可禁止点击该按钮关闭
	                }
	                ,cancel: function(){
	                    //右上角关闭回调
	                    data.elem.checked=!x;
	                    form.render();
	                    //return false;// 开启该代码可禁止点击该按钮关闭
	                }
	            });  
            
        });

		//监听提交
		form.on('submit(demo1)', function(data) {
			layer.alert(JSON.stringify(data.field), {
				title: '最终的提交信息'
			})
			return false;
		}); 

	});

	function isscore(paid) {
		$.ajax({
			type: 'get',
			url: "{:url('shop/open_prt')}",
			dataType: 'json',
			data: {
				paid: paid
			},
			success: function(data) {
				if(data.code == 200) {
					//					layer.msg(data.msg, {
					//						icon: 1,
					//						time: 1000
					//					});
					location.reload();
				} else {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
				}
			}
		});
	}
	
	function store_switch(store_switch){
		$.ajax({
			type: 'get',
			url: "{:url('shop/store_switch')}",
			dataType: 'json',
			data: {
				store_switch: store_switch
			},
			success: function(data) {
				if(data.code == 200) {
					location.reload();
				} else {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
				}
			}
		});
	}

    function storage_switch(storage_switch){ 
    	$.ajax({
			type: 'post',
			url: "{:url('index/index')}",
			dataType: 'json',
			data: {
				storage_switch: storage_switch
			},
			success: function(data) { 
				if(data.code == 200) {
					location.reload();
				} else {
					layer.msg(data.msg, {
						icon: 1,
						time: 1000
					});
				}
			}
		});
    }
    
    //分佣
    function fy(){
    	var type = $("input[name='type']:checked").val();  
    	$.ajax({
			type: 'post',
			url: "{:url('index/fy')}",
			dataType: 'json',
			data: {
				type: type
			},
			success: function(data) { 
				layer.msg(data.msg, {
						icon: 1,
						time: 1000
				});
			}
		});
    }
</script>